"""
@FileName：2线程锁.py
@Author：lmz
@Time：2021/5/20 22:55
"""
import threading
import time

count = 0
lock = threading.Lock()

def sub_thread():
    lock.acquire()
    global count
    count +=1
    time.sleep(1)
    print('thread %d'%count)
    lock.release()

for i in range(5):
    t = threading.Thread(target=sub_thread)
    t.start()